<template>
    <div>
        <van-nav-bar
            :title="titles"
            left-arrow
            @click-left="onClickLeft"
        />
        
                    <!-- 优惠券单元格 -->
            <van-coupon-cell
            :chosen-coupon="chosenCoupon"
            @click="showList = true"
            />
            <!-- 优惠券列表 -->
            <van-popup
            v-model:show="showList"
            round
            position="bottom"
            style="height: 90%; padding-top: 4px;"
            >
            <van-coupon-list
                :chosen-coupon="chosenCoupon"
                @change="onChange"
            />
            </van-popup>

    </div>
</template>

<script setup lang="ts">
            

            import { ref } from 'vue';

        
            const titles='优惠卷'
            const onClickLeft = () => history.back();
            // const coupon = {
            // available: 1,
            // condition: '无门槛\n最多优惠12元',
            // reason: '',
            // value: 150,
            // name: '优惠券名称',
            // startAt: 1489104000,
            // endAt: 1514592000,
            // valueDesc: '1.5',
            // unitDesc: '元',
            // };

            // const coupons = ref([coupon]);
            const showList = ref(false);
            const chosenCoupon = ref(-1);

            const onChange = (index: number) => {
            showList.value = false;
            chosenCoupon.value = index;
            };
            // const onExchange = (code: any) => {
            // coupons.value.push(coupon);
            // };


</script>

<style scoped>

</style>